package com.ruoyi.ifmPost.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ifmPost.domain.IfmPost;
import com.ruoyi.ifmPost.service.IIfmPostService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工作岗位Controller
 * 
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/ifmPost/ifmPostm")
public class IfmPostController extends BaseController
{
    @Autowired
    private IIfmPostService ifmPostService;

    /**
     * 查询工作岗位列表
     */
    @PreAuthorize("@ss.hasPermi('ifmPost:ifmPostm:list')")
    @GetMapping("/list")
    public TableDataInfo list(IfmPost ifmPost)
    {
        startPage();
        List<IfmPost> list = ifmPostService.selectIfmPostList(ifmPost);
        return getDataTable(list);
    }

    /**
     * 导出工作岗位列表
     */
    @PreAuthorize("@ss.hasPermi('ifmPost:ifmPostm:export')")
    @Log(title = "工作岗位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IfmPost ifmPost)
    {
        List<IfmPost> list = ifmPostService.selectIfmPostList(ifmPost);
        ExcelUtil<IfmPost> util = new ExcelUtil<IfmPost>(IfmPost.class);
        util.exportExcel(response, list, "工作岗位数据");
    }

    /**
     * 获取工作岗位详细信息
     */
    @PreAuthorize("@ss.hasPermi('ifmPost:ifmPostm:query')")
    @GetMapping(value = "/{postId}")
    public AjaxResult getInfo(@PathVariable("postId") Long postId)
    {
        return success(ifmPostService.selectIfmPostByPostId(postId));
    }

    /**
     * 新增工作岗位
     */
    @PreAuthorize("@ss.hasPermi('ifmPost:ifmPostm:add')")
    @Log(title = "工作岗位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IfmPost ifmPost)
    {
        return toAjax(ifmPostService.insertIfmPost(ifmPost));
    }

    /**
     * 修改工作岗位
     */
    @PreAuthorize("@ss.hasPermi('ifmPost:ifmPostm:edit')")
    @Log(title = "工作岗位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IfmPost ifmPost)
    {
        return toAjax(ifmPostService.updateIfmPost(ifmPost));
    }

    /**
     * 删除工作岗位
     */
    @PreAuthorize("@ss.hasPermi('ifmPost:ifmPostm:remove')")
    @Log(title = "工作岗位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{postIds}")
    public AjaxResult remove(@PathVariable Long[] postIds)
    {
        return toAjax(ifmPostService.deleteIfmPostByPostIds(postIds));
    }
}
